<?php
/**
 * 第三方对接基类
 * User: 13651
 * Time: 2025/9/5 09:54
 */

namespace App\Extensions;

class BaseService
{
    protected static $instance = [];

    private function __construct(){$this->init();}
    private function __clone(){}

    protected function init(){}

    public static function getInstance()
    {
        if ((static::$instance[static::class] ?? []) instanceof static) {
            return static::$instance[static::class];
        }
        return static::$instance[static::class] = new static();
    }

    public function responSuccess(string $message='success')
    {
        return json_encode(['status'=>1,'message'=>$message]);
    }

    public function responError(string $message='请稍后再试!')
    {
        return json_encode(['status'=>2,'message'=>$message]);
    }

    public function serviceSuccess(string $message='success')
    {
        return ['status'=>1,'message'=>$message];
    }

    public function serviceError(string $message='请稍后再试!')
    {
        return ['status'=>2,'message'=>$message];
    }
}